﻿@using AntDesign.Select
@rendermode InteractiveServer

@inherits AComponentEditBase<ApplicationViewModel, string>

<div style="margin-bottom:30px;">
	<Form @ref="form"
		  Model="@model"
		  ValidateMode="FormValidateMode.Rules"
		  ValidateOnChange="true"
		  OnFinish="OnFinish"
		  OnFinishFailed="OnFinishFailed"
		  LabelColSpan="8" WrapperColSpan="16">

		<Row Gutter="24">
			<Col Span="24">
			<FormItem Label="名称" LabelColSpan="8" WrapperColSpan="20" Rules="RequiredRules">
				<Input @ref="inputFirst" AutoFocus ShowCount MaxLength="64" Width="100%" @bind-Value="@context.DisplayName" />
			</FormItem>
			</Col>
		</Row>
		<Row Gutter="24">
			<Col Span="24">
			<FormItem Label="ClientId" LabelColSpan="8" WrapperColSpan="20" Rules="RequiredRules">
				<Input ShowCount MaxLength="64" Width="100%" @bind-Value="@context.ClientId" />
			</FormItem>
			</Col>
		</Row>

		<Row Gutter="24">
			<Col Span="24">
			<Tooltip>
				<TitleTemplate>
					<Icon Type="@IconType.Outline.Warning" /> 修改变更时,都需要生成新的密钥,以保证安全,请妥善保.
				</TitleTemplate>
				<ChildContent>
					<FormItem Label="ClientSecret" LabelColSpan="8" WrapperColSpan="20" Rules="RequiredRules">

						<InputPassword ShowCount MaxLength="64" Width="100%" @bind-Value="@context.ClientSecret">
							<AddOnAfter>
								<Tooltip Title="生成密钥">
									<Button Type="ButtonType.Link" Icon="@IconType.Outline.Code" Size=" ButtonSize.Small" OnClick="onGenSecret" />
								</Tooltip>
								<Tooltip Title="复制密钥">
									<Button Type="ButtonType.Link" Icon="@IconType.Outline.Copy" Size=" ButtonSize.Small" OnClick="onCopy" />
								</Tooltip>
							</AddOnAfter>
						</InputPassword>
					</FormItem>
				</ChildContent>
			</Tooltip>
			</Col>
		</Row>
		<Row Gutter="24">
			<Col Span="12">
			<FormItem Label="是否启用" LabelColOffset="8">
				<Switch @bind-Value="@context.Status" CheckedChildren="开" UnCheckedChildren="关"></Switch>
			</FormItem>
			</Col>
			<Col Span="12">
			<FormItem Label="排序" LabelColSpan="6">
				<AntDesign.InputNumber @bind-Value="@context.OrderNo" Min="1" Max="9999" DefaultValue="100" Width="100%" PlaceHolder="排序"></AntDesign.InputNumber>
			</FormItem>
			</Col>
		</Row>
		<Row Gutter="24">
			<Col Span="24">
			<FormItem Label="权限" LabelColSpan="8" WrapperColSpan="20">
				<Select Mode="SelectMode.Multiple"
						Placeholder="Please select"
						@bind-Values="@context.Permissions"
						TItemValue="string"
						TItem="string"
						OnSelectedItemsChanged="OnSelectedPermissionsChangedHandler"
						MaxTagCount="5"
						Style="max-width:300px;"
						EnableSearch EnableVirtualization
						AllowClear>
					<SelectOptions>
						@foreach (var item in _AllPermissions)
						{
							<SelectOption TItemValue="string" TItem="string" Value=@item Label=@item />
						}
					</SelectOptions>
				</Select>
			</FormItem>

			</Col>
		</Row>
		<Row Gutter="24">
			<Col Span="24">
			<FormItem Label="备注" LabelColSpan="8" WrapperColSpan="20">
				<TextArea ShowCount MaxLength="200" Width="100%" Placeholder="备注" @bind-Value="@context.Remark"></TextArea>
			</FormItem>
			</Col>
		</Row>
	</Form>
</div>
<textarea id="fallbackTextArea" style="position: absolute; left: -9999px;" @ref="copyRef"></textarea>